<template>
  <div class="header">
    <span>姓名：xxxx &nbsp;&nbsp;&nbsp;&nbsp;</span>
    <el-dropdown @command="handleCommand">
      <span class="el-dropdown-link">
        操作<i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown" >
        <el-dropdown-item command="loginOut">退出登陆</el-dropdown-item>
        <el-dropdown-item>修改密码</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>
<script>
import request from "@/utils/request.js"
export default {
  methods: {
    handleCommand(val) {
      console.log(val,20)
      if(val == 'loginOut') {
        this.loginOut()
      }
    },
    loginOut() {
      // get 传递参数有两种方式，皆是根据后端接收方式定
      // 默认get 传参是拼接在路径上的参数
      // 如果后端接收参数是从请求对象当中获取，那么传参方式就是和post 保持一致
      request.get('/loginOut?token=001&id=1',{token: '001'}).then(res => {
        localStorage.clear()
        this.$router.push({
          path: '/login'
        })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.header {
  span {
    color: #ffffff;
  }
}
</style>